<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小黑购物车</title>
</head>
<style>
    .box{
        height:300px;
        width:400px;
        border:4px solid #000;
        border-radius:10px;
        margin: 10px auto;
        text-align: center;
    }
    .text1{
        font-size: 40px;
        font-weight: bold;
        line-height: 250px;
        text-align: center;
    }
    button{
        float: left;
        height:30px;
        width:100px;
        margin-left: 50px;
    }
</style>
<body>
    <div id="app">
        <div class="box">
            <div class="text1">小黑自动售货机</div>
            <button v-on:click="buy(5)">可乐5元</button>
            <button v-on:click="buy(10)">咖啡10元</button>
            <br>
            <div>余额：{{money}}</div>
        </div>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
<script>
    const app = new Vue({
        el:'#app',
        data:{
            money:1200
        },
        methods:{
            //传参的话， 标签那边传参数
            //这边响应的括号里面写几个参数就行了
            //第一个参数默认为当前事件的 event 
            buy(price){
                this.money = this.money - price ;
            }
        }
    })
</script>
</html>